Skip to content

Conversation

@Artuomka
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings January 14, 2026 15:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds dashboard and widget entities to support dashboard visualization functionality. The changes introduce database tables, entity models, repositories, use cases, controllers, and comprehensive end-to-end tests for both SaaS and non-SaaS environments.

Changes:

  • Added DashboardEntity and DashboardWidgetEntity with supporting database migration
  • Implemented full CRUD operations for dashboards and widgets with validation and authorization
  • Added comprehensive e2e tests covering dashboard creation, updates, deletion, and widget management
  • Integrated widgets with existing saved query functionality

Reviewed changes

Copilot reviewed 44 out of 44 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
backend/src/migrations/1768393822639-AddDashboardAndDashboardWigetEntities.ts Database migration creating dashboard and dashboard_widget tables with foreign key relationships
backend/src/entities/visualizations/dashboard/dashboard.entity.ts Dashboard entity definition with TypeORM decorators and relationships
backend/src/entities/visualizations/dashboard/dashboard-widget.entity.ts Widget entity with JSON serialization/deserialization for widget_options
backend/src/entities/visualizations/dashboard/dashboards.controller.ts REST API endpoints for dashboard CRUD operations with guards and Swagger documentation
backend/src/entities/visualizations/dashboard/dashboard-widgets.controller.ts REST API endpoints for widget CRUD operations
backend/src/entities/visualizations/dashboard/use-cases/*.ts Business logic for dashboard and widget operations including validation
backend/src/entities/visualizations/dashboard/repository/*.ts Custom repository extensions for database queries
backend/test/ava-tests/saas-tests/dashboard-e2e.test.ts Comprehensive e2e tests for SaaS environment
backend/test/ava-tests/non-saas-tests/non-saas-dashboard-e2e.test.ts Comprehensive e2e tests for non-SaaS environment
backend/src/common/application/global-database-context.ts Added dashboard and widget repositories to global context
backend/src/app.module.ts Registered DashboardModule in application

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +3 to +4
export class AddDashboardAndDashboardWigetEntities1768393822639 implements MigrationInterface {
name = 'AddDashboardAndDashboardWigetEntities1768393822639';
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The migration class name contains a typo: "Wiget" instead of "Widget". This should be "AddDashboardAndDashboardWidgetEntities1768393822639" to match the actual table name "dashboard_widget" being created.

Copilot uses AI. Check for mistakes.
Comment on lines +22 to +23
@Column({ type: 'uuid' })
connection_id: string;
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type inconsistency: The DashboardEntity defines connection_id as uuid type (line 22), but ConnectionEntity.id is varchar(38). The migration correctly uses "character varying" but the entity decorator should be @column({ type: 'varchar', length: 38 }) to match the connection table's id type and the migration.

Copilot uses AI. Check for mistakes.
.set('Accept', 'application/json');

const createDashboardRO = JSON.parse(createDashboard.text);
console.log('🚀 ~ createDashboardRO:', createDashboardRO);
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console.log statement should be removed before merging to production.

Copilot uses AI. Check for mistakes.
position_y: widget.position_y,
width: widget.width,
height: widget.height,
widget_options: widget.widget_options as unknown as Record<string, unknown> | null,
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type casting with 'as unknown as' is used here, which bypasses TypeScript's type checking. The widget_options field is typed as string | null in the entity but is being parsed to an object in AfterLoad. Consider creating a proper type guard or validation function to ensure type safety instead of double casting.

Copilot uses AI. Check for mistakes.
Comment on lines +6 to +21
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE "dashboard" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "name" character varying NOT NULL, "description" text, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP NOT NULL DEFAULT now(), "connection_id" character varying NOT NULL, CONSTRAINT "PK_233ed28fa3a1f9fbe743f571f75" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE TABLE "dashboard_widget" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "widget_type" character varying NOT NULL, "name" character varying, "description" text, "position_x" integer NOT NULL DEFAULT '0', "position_y" integer NOT NULL DEFAULT '0', "width" integer NOT NULL DEFAULT '4', "height" integer NOT NULL DEFAULT '3', "widget_options" json, "dashboard_id" uuid NOT NULL, "query_id" uuid, CONSTRAINT "PK_d776e45a42322c53e9167b00ead" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`ALTER TABLE "dashboard" ADD CONSTRAINT "FK_61891f58faf0242381786d60334" FOREIGN KEY ("connection_id") REFERENCES "connection"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
);
await queryRunner.query(
`ALTER TABLE "dashboard_widget" ADD CONSTRAINT "FK_1d4cbbe2829d760116ce4472bd5" FOREIGN KEY ("dashboard_id") REFERENCES "dashboard"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
);
await queryRunner.query(
`ALTER TABLE "dashboard_widget" ADD CONSTRAINT "FK_2d30b309abbaf0e051fd89560b9" FOREIGN KEY ("query_id") REFERENCES "saved_db_query"("id") ON DELETE SET NULL ON UPDATE NO ACTION`,
);
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding database indexes for frequently queried columns. The dashboard table should have an index on connection_id, and the dashboard_widget table should have indexes on dashboard_id and query_id to optimize query performance for the repository methods that filter on these columns.

Copilot uses AI. Check for mistakes.
@Artuomka Artuomka enabled auto-merge January 14, 2026 16:44
@Artuomka Artuomka merged commit 4d809c6 into main Jan 14, 2026
18 of 19 checks passed
@Artuomka Artuomka deleted the backend_dashboards branch January 14, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants